home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap16 / dun16_7.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1.0 KB  |  39 lines

  1. <HTML>
  2.  
  3. <HEAD>
  4.  
  5.   <TITLE>Displaying Context-Sensitive Menus Using Mouse Position</TITLE>
  6.  
  7.   <STYLE>
  8.  
  9.     .contextMenu  { position: absolute; background-color: #CCCCCC;
  10.  
  11.                     font-family: arial, helvetica, sans-serif;
  12.  
  13.                     font-size: 10pt; margin: 10; border: solid 1 gray; }
  14.  
  15.   </STYLE>
  16.  
  17.  
  18.  
  19.   <SCRIPT>
  20.  
  21.     function showDefaultMenu()
  22.  
  23.     {
  24.  
  25.       if (event.ctrlKey)
  26.  
  27.       {
  28.  
  29.         document.all.defaultMenu.style.left = event.x;
  30.  
  31.         document.all.defaultMenu.style.top = event.y;
  32.  
  33.         document.all.defaultMenu.style.display = "";
  34.  
  35.       }
  36.  
  37.     }
  38.  
  39.  
  40.  
  41.     function hideDefaultMenu()
  42.  
  43.     {
  44.  
  45.       document.all.defaultMenu.style.display = "none";
  46.  
  47.     }
  48.  
  49.   </SCRIPT>
  50.  
  51. </HEAD>
  52.  
  53.  
  54.  
  55. <BODY onMouseDown="showDefaultMenu();" onMouseUp="hideDefaultMenu();">
  56.  
  57. <H2>Displaying Context-Sensitive Menus Using Mouse Position</H2>
  58.  
  59.  
  60.  
  61. <DIV ID=defaultMenu CLASS=contextMenu STYLE="display: none; width: 100;">
  62.  
  63. Cut<BR>
  64.  
  65. Copy<BR>
  66.  
  67. Paste<BR>
  68.  
  69. </DIV>
  70.  
  71.  
  72.  
  73. </BODY>
  74.  
  75. </HTML>
  76.  
  77.